package com.itrip.service.impl;

import com.itrip.dao.ItripHotelRoomMapper;
import com.itrip.dao.ItripUserMapper;
import com.itrip.dao.ex.UserMapperEX;
import com.itrip.pojo.ItripHotelRoom;
import com.itrip.pojo.ItripUser;
import com.itrip.service.UserService;
import com.itrip.vo.user.LoginVO;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private ItripUserMapper userMapper;

    @Resource
    private ItripHotelRoomMapper roomMapper;

    @Resource
    private UserMapperEX userMapperEX;
    @Override
    public List<ItripUser> getUserList() {
        return userMapper.getUserList();
    }

    @Override
    public ItripUser getUserByLogin(LoginVO loginVO) {
        return userMapperEX.getUserByLogin(loginVO);
    }

    @Override
    public int addUser(ItripUser user) {
        return userMapper.insertSelective(user);
    }

    @Override
    public int getUserCodeCount(String userCode) {
        return userMapperEX.getUserCodeCount(userCode);
    }

    @CacheEvict(value = "hotelRoom", allEntries = true)
    @Override
    public int updateRoomBook(ItripHotelRoom room) {
        return roomMapper.updateByPrimaryKeySelective(room);
    }
}
